Skip to content

fix: strip export-from server data exports in client transform#7

Open
JaredStowell wants to merge 1 commit intomainfrom
codex/fix-stripserverexports-to-handle-re-exports
Open

fix: strip export-from server data exports in client transform#7
JaredStowell wants to merge 1 commit intomainfrom
codex/fix-stripserverexports-to-handle-re-exports

Conversation

@JaredStowell
Copy link
Owner

Motivation

  • The client-side transform stripServerExports skipped ExportNamedDeclaration nodes that have a source (patterns like export { getServerSideProps } from './server'), leaving server-only data-fetching exports in client bundles and potentially exposing server-only code.

Description

  • Update stripServerExports in packages/vinext/src/index.ts to process ExportNamedDeclaration specifiers regardless of node.source so export ... from '...' patterns are handled.
  • Preserve non-server re-exported specifiers (including their from '...' source) while replacing server-only specifiers with stubbed export const <name> = undefined; lines for mixed re-exports.
  • Add regression tests in tests/build-optimization.test.ts covering pure export-from server exports and mixed specifier cases to prevent regressions.

Testing

  • Ran the focused test: pnpm vitest run tests/build-optimization.test.ts -t "handles export-from", and the targeted tests passed.
  • Added tests are part of tests/build-optimization.test.ts and the new cases pass under the targeted Vitest run.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant